package com.hou.cassecurity.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
public class UserController {
	private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
	@RequestMapping("/login")
	public String login() {
		
		return "welcome";
	}
	
/*	@PreAuthorize("hasRole('USER')")*/
	@RequestMapping("/logout")
	public String logout() {
		
		return "logout";
	}
	
	@RequestMapping("/index")
	public String index() throws IOException {
		return "index";
	}
	/*@PreAuthorize("hasRole('USER')")*/
	@RequestMapping("/welcome")
	public String welcome() {

		return "welcome";
	}
	@RequestMapping("/test")
	public String test(String orgCode,String deptCode) {

		return "test"+orgCode+deptCode;
	}
	@PreAuthorize("hasRole('ADMIN')")
	@RequestMapping("/admin")
	public String admin() {
		
		return "admin";
	}

	@RequestMapping("/a")
	public String a() {

		return "a/a";
	}
}
